﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ProjScan.RecordManager.AssetData;
using ProjScan.Tools;
using UnityEditor;
using UnityEngine;

namespace ProjScan.RecordManager
{
	// Token: 0x02000273 RID: 627
	internal class AnimatorControllerRecordManager : RecordManagerBase<AnimatorControllerAssetData>
	{
		// Token: 0x060010C4 RID: 4292 RVA: 0x0004D770 File Offset: 0x0004B970
		public override void PrepareAssets()
		{
			this.datas = new List<AnimatorControllerAssetData>();
			string[] array = new string[]
			{
				"controller"
			};
			int num = AssetPathManager.Instance.artPathList.Length;
			for (int i = 0; i < num; i++)
			{
				bool isEditor = Singleton<ScanInfo>.Instance.isEditor;
				if (isEditor)
				{
					EditorUtility.DisplayProgressBar("Proj Scan [" + this.TableTag + "]", string.Concat(new string[]
					{
						"Preparing ",
						this.TableTag,
						"(",
						this.datas.Count.ToString(),
						")..."
					}), (float)i * 1f / (float)num);
				}
				string text = AssetPathManager.Instance.artPathList[i];
				string text2 = Path.GetExtension(text).ToLower().Replace(".", "");
				bool flag = Enumerable.Contains<string>(array, text2);
				if (flag)
				{
					this.ActiveAllRecord();
					bool flag2 = this.CheckAssetPathRules(text);
					if (flag2)
					{
						RuntimeAnimatorController runtimeAnimatorController = AssetDatabase.LoadAssetAtPath(text, typeof(RuntimeAnimatorController)) as RuntimeAnimatorController;
						int id = AssetPathManager.Instance.GetID(Path.GetDirectoryName(text));
						bool flag3 = runtimeAnimatorController != null;
						if (flag3)
						{
							AnimatorControllerAssetData animatorControllerAssetData = new AnimatorControllerAssetData(id, text, runtimeAnimatorController);
							animatorControllerAssetData.id = this.datas.Count;
							this.ValidateAsset(animatorControllerAssetData);
							animatorControllerAssetData.Reset();
							this.datas.Add(animatorControllerAssetData);
							bool flag4 = this.datas.Count % 100 == 0;
							if (flag4)
							{
								ToolsHelper.GC();
							}
						}
					}
				}
			}
		}

		// Token: 0x17000372 RID: 882
		// (get) Token: 0x060010C5 RID: 4293 RVA: 0x0004D924 File Offset: 0x0004BB24
		public override string TableTag
		{
			get
			{
				return "animatorcontroller";
			}
		}
	}
}
